package com.wngbms.netty.seatdemo.service;

import com.wngbms.netty.seatdemo.comm.CmdType;

import java.util.HashMap;
import java.util.Map;

public class HandleFactory {

    public static final Map<CmdType, SeatTypeHandler> TYPE_HANDLER_MAP = new HashMap<>();

    static {
        TYPE_HANDLER_MAP.put(HeartBeatHandler.CMD_TYPE, new HeartBeatHandler());
        TYPE_HANDLER_MAP.put(ConnectHandler.CMD_TYPE, new ConnectHandler());
        TYPE_HANDLER_MAP.put(EventHandler.CMD_TYPE, new EventHandler());
        TYPE_HANDLER_MAP.put(ExtraInfoHandler.CMD_TYPE, new ExtraInfoHandler());
        TYPE_HANDLER_MAP.put(HangUpHandler.CMD_TYPE, new HangUpHandler());
        TYPE_HANDLER_MAP.put(OwnerSearchHandler.CMD_TYPE, new OwnerSearchHandler());
        TYPE_HANDLER_MAP.put(EchoHandler.CMD_TYPE, new EchoHandler());
        TYPE_HANDLER_MAP.put(LargeBinaryStreamUploadTestHandler.CMD_TYPE, new LargeBinaryStreamUploadTestHandler());
        TYPE_HANDLER_MAP.put(LargeBinaryStreamDownloadTestHandler.CMD_TYPE, new LargeBinaryStreamDownloadTestHandler());
    }

    public static SeatTypeHandler getHandler(CmdType cmdType) {
        return TYPE_HANDLER_MAP.get(cmdType);
    }

}
